<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Social_media extends MX_Controller {

	public function __construct() {
		parent::__construct();

		$this->load->model('admin_settings_model');
		$this->load->model(array('admin_commoncall','admin_settings_model'));
		$this->load->model('settings_model');
			
		$this->template->set_theme('admin');
		$this->template->set_layout('default');
		$this->template->set_partial('side_menu','layouts/side_menu');
		$this->template->set_partial('nav_bar','layouts/nav_bar');
		$this->template->set_partial('footer','footer/footer');


	}
	
	function index(){
		
	$social = $this->admin_settings_model->get_socials(1);
          if ($social) {
            $data['facebook_link'] = $social->facebook;
           	$data['twitter_link'] = $social->twitter;
           	$data['linkedin_link'] = $social->linkedin;
           	$data['google_link'] = $social->googleplus;
           	$data['pinterest_link'] = $social->pinterest;
        }
		
		$this->template->title('Welcome', 'Ypage.com')
		->set_partial('nav_bar','layouts/nav_bar')
		->set_partial('side_menu','layouts/side_menu')
		->build('settings/social_media',$data);
	}
	
	function social_update() {
		$social_facebook = $_POST['facebook_link'];
		$social_twitter = $_POST['twitter_link'];
		$social_linkedin = $_POST['linkedin_link'];
		$social_google = $_POST['google_link'];
		$social_pinterest = $_POST['pinterest_link'];
		$social_data = array(
				'facebook' => $social_facebook,
				'twitter' => $social_twitter,
				'linkedin' => $social_linkedin,
				'googleplus' => $social_google,
				'pinterest' => $social_pinterest,
		);
		
		//var_dump($social_data);
		//die();
		//if ($this->config->item('mode') != 'DEMO')
		$this->db->update('social', $social_data);
		$this->session->set_flashdata('message', 'Social Updated Sucessfully..........');
		redirect('secure/settings/social_media');
	}
}